package com.fowo.api.controller.shipment.fbainvoice;

import com.fowo.api.model.wms.order.WmsOrderBatchStockOutAction;
import com.fowo.api.service.WmsOrderService;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.util.List;

@Component
public class wmsOrderBatchStockOutAction implements WmsOrderBatchStockOutAction {

    @Resource
    private WmsOrderService wmsOrderService;


    @Transactional(rollbackFor = Exception.class)
    @Override
    public void run(List<Long> idList) throws Exception {
        idList.forEach(x -> {
            try {
                wmsOrderService.stockOut(x);
            } catch (Exception e) {
                throw new RuntimeException(e);
            }
        });
    }
}
